package com.xuecheng.system.controller;

import com.xuecheng.system.model.po.Dictionary;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.system.service.DictionaryService;

import java.util.List;

@Api("数据字典管理接口")
@Slf4j
@RestController
@RequestMapping("/dictionary")
public class DictionaryController {
    @Autowired
    private DictionaryService dictionaryService;

    @ApiOperation("查询所有数据字典")
    @GetMapping("/all")
    public List<Dictionary> queryAll(){
        return dictionaryService.list();
    }

    @ApiOperation("根据字典代码查询对应的字典")
    @RequestMapping("/code/{code}")
    public Dictionary getByCode(@PathVariable String code){
        return dictionaryService.getByCode(code);
    }
}
